.PHONY: all clean utils boot kernel

include ekos-conf.mk

all: boot.img core.sym

boot.img: utils boot kernel
	${DD} if=/dev/zero of=$@~ count=10000 2>/dev/null
	${DD} if=boot/boot_s0 of=$@~ conv=notrunc 2>/dev/null
	${DD} if=boot/boot_s1 of=$@~ seek=1 conv=notrunc count=800 2>/dev/null
	${DD} if=kernel/kernel of=$@~ seek=5 conv=notrunc 2>/dev/null
	${MV} $@~ $@
	
utils:
	${MAKE} -C utils

boot:
	${MAKE} -C boot
	
kernel:
	${MAKE} -C kernel

core.sym: boot.img
	${SORT} kernel/kernel.sym user/user.sym > core.sym

clean:
	${MAKE} -C utils/ clean
	${MAKE} -C boot/ clean
	${MAKE} -C kernel/ clean
	-${RM} core.sym
	-${RM} boot.img

qemu: clean all
	./start
